package com.anjho.utils;

public class Security {
	
	/**
	 * @param String password
	 * @return String MD5password
	 */
	public static String getMD5(String password) {
		try {
			java.security.MessageDigest md = java.security.MessageDigest
					.getInstance("MD5");
			md.update(password.getBytes());
			byte[] hash = md.digest();
			StringBuffer hexString = new StringBuffer();
			for (int i = 0; i < hash.length; i++) {
				if ((0xff & hash[i]) < 0x10)
					hexString.append("0"
							+ Integer.toHexString((0xFF & hash[i])));
				else
					hexString.append(Integer.toHexString(0xFF & hash[i]));
			}
			password = hexString.toString();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return password;
	}

}
